#!/usr/bin/env python 
#+_+ coding:utf-8 +_+

import httplib
import hashlib

def md5(*args):
    md5Ctx = hashlib.md5()
    for arg in args:
        md5Ctx.update(str(arg))
    return md5Ctx.hexdigest()


httpClient = httplib.HTTPConnection('localhost', 8080, timeout=30)  

uid = 1
index = 0
count = 5
ticket   = "bd637611abfe504f1ad40547af91687f"

contents = [str(index),str(count),str(uid),ticket]

contents = sorted(contents)
signature = md5(*contents)


params = dict(uid=uid,signature=signature,index=index,count=count)

req="/apping/demo/topnews?uid={uid}&&signature={signature}&&index={index}&&count={count}".format(**params)

httpClient.request('GET', req)  
  
response = httpClient.getresponse()  
print response.status  
print response.reason  
print response.read()
